<!--
**********************************************************
* @Author: 张小平
* @Date:   2024-05-01
* @Email:  qqshuqian@163.com
* @Last modified: 最后修改日期
* @Description: 文件描述
**********************************************************
-->
<template>
  <div class="node" :class="{active: isActive}" @click="handleItem">
    <div class="head" :class="[name]">
      <div class="title">{{title}}</div>
      <div v-if="isDelete" class="delete" @click.stop="handleDelete">×</div>
    </div>
    <div class="content">
      <div class="man"><div class="text"><slot /></div></div>
      <div class="enter">&rsaquo;</div>
    </div>
  </div>
</template>

<script>
import { itemType } from '@/framework-code/utils/constants'
export default {
  props: {
    isActive: {
      type: Boolean,
      default: false
    },
    item: {
      type: Object,
      default: () => {}
    },
    name: {
      type: String,
      default: itemType.start
    }
  },
  computed: {
    title() {
      const {
        taskName
      } = this.item

      if (taskName) {
        return taskName
      }

      switch (this.name) {
        case itemType.todo:
          return '办理人'
        case itemType.cc:
          return '抄送人'
        default:
          return '提交人'
      }
    },
    isDelete() {
      return this.name !== itemType.start
    }
  },
  methods: {
    handleItem(e) {
      this.$emit('on-set', e, this.item)
    },
    handleDelete(e) {
      this.$emit('on-del', e, this.item)
    }
  }
}
</script>

<style lang="scss" scoped>
@import './item.scss';
</style>
